package com.example.demo.controller;

import com.example.demo.service.TestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
public class TestController {

//  连接mysql数据库的测试
//  @Autowired
//  private TestService testService;
//
//  @RequestMapping("/stuData")
//  public Map getData2(){
//    Map<String, Object> map = new HashMap<>();
//
//    List<Student> result = testService.getAll();
//
//    map.put("data", result);
//
//    return map;
//  }

//  使用了service的测试
  @Autowired
  private TestService testService;

  @RequestMapping("/tryService")
  public int testView(){
    return testService.getData(6);
  }

//  输出数据的测试
  @RequestMapping("/dataTest")
  public Map getData(){
    Map<String,Object> map = new HashMap<>();
    map.put("zhang",30);
    map.put("meng","second");
    return map;
  }

//  输出hello world的测试
  @RequestMapping("/hello")
  public String hello(){
    return"Hello World!";
  }
}
